Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added getHash method in SQLFilter to avoid caching the filtered queries #8393

Open
wants to merge 1 commit into
base: old-prototype-3.x
Choose a base branch
from

Conversation

alecszaharia
Copy link

I introduced a new final method getHash on SQLFilter that generates a hash based on the called class name and all the parameters. Also the FilterCollection::getHash() was modified to use the getHash method from SQLFilter.

This is implemented acording to @beberlei's recomandation see the discussion bellow.

#3955 (comment)

Copy link
Member

@beberlei beberlei left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Few change requests.

$hash = get_class($this).$parameterCount;
foreach ($this->parameters as $name => $param) {
if (is_object($param['value'])) {
$valueHash = spl_object_hash($param['value']);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spl_object_hash is not reliable within and across requests. You need to serialize the parameter. the API of setParameter only allows stirngs anyways, it is not enforced though. But that should allow us to do this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about changing this method to

final public function getHash()
{
        return self::class.$this;
}

I don't think the serialize() will have a big performance impact here.

@@ -95,6 +95,17 @@ public function testGetFilter() : void

self::assertInstanceOf(MyFilter::class, $filterCollection->getFilter(self::TEST_FILTER));
}

public function testGetHash()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also add an object based parameter and see serialize.

Base automatically changed from master to old-prototype-3.x February 23, 2021 08:19
alecszaharia added a commit to bagrinsergiu/doctrine-orm that referenced this pull request Apr 2, 2021
alecszaharia added a commit to bagrinsergiu/doctrine-orm that referenced this pull request Apr 5, 2021
alecszaharia added a commit to bagrinsergiu/doctrine-orm that referenced this pull request Apr 20, 2021
alecszaharia added a commit to bagrinsergiu/doctrine-orm that referenced this pull request Apr 20, 2021
alecszaharia added a commit to bagrinsergiu/doctrine-orm that referenced this pull request Apr 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants